#include "threadpool.h"
int recvn(int sockfd, void *buf, ssize_t length){
    char *p = (char *)buf;
    // 还剩下多少字节需要接收
    int lef =length;
    int sret = -1;
    while(lef > 0){
         sret = recv(sockfd,p,lef,0);
        if(sret == 0) break;

        else{
            if(sret < 0){
                printf("接收出错！\n");
                return -1;
            }
            lef -= sret;
            p += sret;
        }
    }
    return  length - lef;
} int sendn(int sockfd, void *buf, ssize_t length){
     char *p = (char *)buf;
     int lef = length; 
     int sret = -1;
     while(lef > 0){
         sret = send(sockfd,p,length,0);
 
         if(sret < 0){                                                   
             printf("发送出错！\n");
             return -1;
         }
            lef -=sret;
            p +=sret;
        }
     return length - lef;
 }


